//
//  DKMsgAlertCollectionCell.m
//  DanKU
//
//  Created by 蓝鳍互娱 on 2023/12/8.
//

#import "DKMsgAlertCollectionCell.h"
@interface DKMsgAlertCollectionCell()
@property (nonatomic,strong) UILabel *msgAlertLab;
@end
@implementation DKMsgAlertCollectionCell
-(instancetype)initWithFrame:(CGRect)frame{
    if(self == [super initWithFrame:frame]){
        self.backgroundColor = UIColor.clearColor;
        [self creatSubView];
    }
    return self;
}
- (void)creatSubView{
    UIView *dk_MsgAlertView = [[UIView alloc] init];
    dk_MsgAlertView.backgroundColor = DK_HexA(@"#000000",0.78);
    dk_MsgAlertView.layer.cornerRadius = DK_IsWidthScale(10);
    dk_MsgAlertView.clipsToBounds = YES;
    [self.contentView addSubview:dk_MsgAlertView];
    [dk_MsgAlertView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(15)));
        make.right.equalTo(@(-DK_IsWidthScale(15)));
        make.top.equalTo(@(DK_IsWidthScale(30)));
        make.height.equalTo(@(DK_IsWidthScale(60)));
    }];
    UIImageView* dk_MsgAlertImageView = [[UIImageView alloc] init];
    dk_MsgAlertImageView.userInteractionEnabled = YES;
    dk_MsgAlertImageView.image = DK_GetImage(@"dk_MsgIcon");
    [dk_MsgAlertView addSubview:dk_MsgAlertImageView];
    [dk_MsgAlertImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(20)));
        make.centerY.equalTo(dk_MsgAlertView);
        make.width.equalTo(@(DK_IsWidthScale(34)));
        make.height.equalTo(@(DK_IsWidthScale(34)));
    }];
    self.msgAlertLab = [[UILabel alloc] init];
    self.msgAlertLab.textColor = DK_Hex(@"#FFFFFF");
    self.msgAlertLab.font = DK_FONT_Medium(14);
    [dk_MsgAlertView addSubview:self.msgAlertLab];
    [self.msgAlertLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(dk_MsgAlertImageView.mas_right).offset(DK_IsWidthScale(10));
        make.centerY.equalTo(dk_MsgAlertImageView);
        make.height.equalTo(@(DK_IsWidthScale(20)));
    }];
    UIButton * msgAlertCloseBtn = [[UIButton alloc] init];
    [msgAlertCloseBtn setBackgroundImage:DK_GetImage(@"dk_MsgCloseIcon") forState:UIControlStateNormal];
    [msgAlertCloseBtn addTarget:self action:@selector(msgAlertClose) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:msgAlertCloseBtn];
    [msgAlertCloseBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.right.equalTo(@(-DK_IsWidthScale(15)));
        make.width.equalTo(@(DK_IsWidthScale(20)));
        make.height.equalTo(@(DK_IsWidthScale(20)));
    }];
    UIImageView* msgAlertGoImgView = [[UIImageView alloc] init];
    msgAlertGoImgView.userInteractionEnabled = YES;
    msgAlertGoImgView.image = DK_GetImage(@"dk_MsgGoIcon");
    [dk_MsgAlertView addSubview:msgAlertGoImgView];
    [msgAlertGoImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-DK_IsWidthScale(15)));
        make.centerY.equalTo(dk_MsgAlertView);
        make.width.equalTo(@(DK_IsWidthScale(16)));
        make.height.equalTo(@(DK_IsWidthScale(16)));
    }];
    UIButton * msgAlertGoBtn = [[UIButton alloc] init];
    [msgAlertGoBtn addTarget:self action:@selector(msgAlertGo) forControlEvents:UIControlEventTouchUpInside];
    [dk_MsgAlertView addSubview:msgAlertGoBtn];
    [msgAlertGoBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-DK_IsWidthScale(0)));
        make.centerY.equalTo(dk_MsgAlertView);
        make.left.equalTo(@(DK_IsWidthScale(0)));
        make.height.equalTo(@(DK_IsWidthScale(16)));
    }];
}
-(void)setSettled:(NSString *)settled{
    _settled = settled;
    if([_settled isEqualToString:@"1"]){
        self.msgAlertLab.text = @"The payment is successful";
    }else{
        self.msgAlertLab.text = @"Your application is under review";
    }
}
- (void)msgAlertClose{
    if(self.MsgAlertCloseBlock){
        self.MsgAlertCloseBlock(self.settled);
    }
}
- (void)msgAlertGo{
    if(self.MsgAlertGoBlock){
        self.MsgAlertGoBlock(self.settled);
    }
}
@end
